package org.ezplatform.office.meeting.setting.boardroom.service;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.ezplatform.cloud.api.component.popuser.PopUserScopeUtilService;
import org.ezplatform.cloud.api.system.user.UserApiService;
import org.ezplatform.component.permission.service.CmpPermissionService;
import org.ezplatform.component.permission.utils.CmpPermissionConstant;
import org.ezplatform.core.common.WebUser;
import org.ezplatform.core.dao.jpa.JpaBaseDao;
import org.ezplatform.core.pagination.PropertyFilter;
import org.ezplatform.core.service.BaseService;
import org.ezplatform.office.meeting.info.entity.ApplyRecord;
import org.ezplatform.office.meeting.info.service.ApplyRecordDingService;
import org.ezplatform.office.meeting.info.service.ApplyRecordService;
import org.ezplatform.office.meeting.setting.boardroom.dao.BoardroomSetDao;
import org.ezplatform.office.meeting.setting.boardroom.entity.BoardroomSet;
import org.ezplatform.office.meeting.setting.category.entity.BoardroomCategorySet;
import org.ezplatform.office.meeting.setting.category.service.BoardroomCategorySetService;
import org.ezplatform.office.meeting.setting.serve.service.ServeSetService;
import org.ezplatform.util.DateUtils;
import org.ezplatform.util.SqlUtils;
import org.ezplatform.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BoardroomSetService extends BaseService<BoardroomSet, String>{
	private final static Logger LOGGER = LoggerFactory.getLogger(BoardroomSetService.class);
    @Autowired
    private BoardroomSetDao dao;
    @Lazy
    @Autowired
    private ApplyRecordService applyRecordService;
    @Lazy
    @Autowired
	private BoardroomCategorySetService boardroomCategorySetService;
    @Lazy
    @Autowired
    private ServeSetService serveSetService;
    @Lazy
    @Autowired
    private BoardroomCategorySetService categoryDingServvice;
    @Lazy
    @Autowired
    private ApplyRecordDingService applyRecordDingService;
    @Lazy
    @Autowired
    private PopUserScopeUtilService popUserScopeUtilService;
    
    @Autowired
    private UserApiService userApiService;
    
    @Override
    protected JpaBaseDao<BoardroomSet, String> getEntityDao() {
        return dao;
    }
    
    @Autowired
   	private CmpPermissionService cmpPermissionService;
    

    /**
     * 验证
     * @param id
     * @param checkdata
     * @param type
     * @param corpId
     * @return
     */
    public String checkBoardroomSet(String id, String checkdata, int type, String corpId) {
        String msg = "";
        List<BoardroomSet> list = new ArrayList<BoardroomSet>();
        if (type == 1) {// 验证名称
            if (StringUtils.isNotBlank(id)) {// 编辑
                list = this.dao.getBoardroomSetByName(id, checkdata, corpId);
            } else {// 新建
                list = this.dao.getBoardroomSetSetByName(checkdata, corpId);
            }
        }
        if (list != null && list.size() > 0) {
        	msg = this.getCheckMsgStr(type);
        }
        return msg;
    }
    
    /**
     * 验证报错返回msg信息
     * 
     * @param type
     * @return
     */
    private String getCheckMsgStr(int type) {
        String msg = "";
        switch (type) {
        case 1:
            msg = "您输入的会议室名称已存在";
            break;
        default:
            msg = "";
            break;
        }
        return msg;
    }

    /**
     * 查询会议室管理列表数据
     * @param localPageable
     * @param corpId
     * @param name
     * @return
     */
    public Page getBoardroomSetList(Pageable localPageable, String corpId, String name,WebUser webUser) {
    	LOGGER.debug("-----getBoardroomSetList----");
        Map<String, Object> paramMap = new HashMap<String, Object>();
        StringBuffer sql = new StringBuffer();
        sql.append("select t1.createdBy id, t1.id as dataid, t1.name,t1.cateName,t1.count,t1.address,t1.isOpen,t1.sortNo,t1.createdDate,t1.isApprove from (");
        sql.append(" select ombs.id,ombs.name,ombs.count,ombc.name cateName,");
        sql.append(" ombs.createdDate,ombs.address,ombs.is_open isOpen,ombs.is_approve isApprove,ombs.sort_no sortNo,");
        sql.append(" ombs.createdOrg,ombs.createdBy ");
        sql.append(" from oa_meeting_boardroom_set ombs");
        //sql.append(" left join oa_meeting_apply_record_scope oms on ombs.admin_user_scope = oms.fieldDataValue");
        //sql.append(" left join sys_user sysu on oms.scopeValue = sysu.id");
        sql.append(" left join oa_meeting_boardroom_cate ombc on ombc.id=ombs.category_id ");
        sql.append(" where ombs.corp_id=:corpId ");
        paramMap.put("corpId", corpId);
        if(StringUtils.isNotBlank(name)){
        	name=SqlUtils.escapeNormalChars(name);
            sql.append(" and ombs.name like :name "+SqlUtils.getSQLEscape(name));
            paramMap.put("name", "%"+name+"%");
        }
        sql.append(" ) t1 WHERE 1 = 1 ");
        
        String perSql = cmpPermissionService.getBusinessScopeSql("t1", webUser, "meeting:room:03");
		LOGGER.debug("---perSql:"+perSql);
		sql.append(perSql);
        List localList = new ArrayList();
        String sqlStr = PropertyFilter.getSqlByFilterAndPageable("", sql.toString(), "t1.sortNo asc,t1.createdDate desc", localList, localPageable);
        Page<Map> localPage = super.findByPageNativeSQL(localPageable, sqlStr, paramMap);
        Map<String, String> permissionInfoMap = new HashMap<String, String>();
		// map格式：key-权限编码，value-操作标识
		permissionInfoMap.put("meeting:room:02", CmpPermissionConstant.PERMISSION_NAME_CAN_EDIT);
		permissionInfoMap.put("meeting:room:04", CmpPermissionConstant.PERMISSION_NAME_CAN_DELETE);
		cmpPermissionService.processBaseListByDataScope(localPage.getContent(), webUser, permissionInfoMap, "user");
		for(Map<String,Object> meet:localPage.getContent()) {
			meet.put("id", meet.get("dataid"));
		}
        return localPage;
    }

    /**
     * 查询会议室设置树数据(不需要审批的会议室)
     * @param request
     * @param corpId
     * @return
     */
    public String getBoardroomTreeData(String corpId) {
        int isOpen = 1;
        Map<String, Object> paramMap = new HashMap<String, Object>();

        String sql = "select s.id,s.name from oa_meeting_boardroom_set s ";
        sql +=" left join oa_meeting_boardroom_cate ombcs on s.category_id = ombcs.id ";
        sql += " where s.corp_id = :corpId and ombcs.id is not null and s.is_approve = '1'  ";
        paramMap.put("corpId", corpId);
        sql +=" and s.is_open in(:isOpen)";
        paramMap.put("isOpen", isOpen);
        sql += " ORDER BY s.sort_no asc,s.createdDate desc";

        List menuTree = super.getQueryByNativeSQL(sql.toString(), paramMap).getResultList();

        StringBuffer str = new StringBuffer("");
        str.append("[");
        for (int i = 0; i < menuTree.size(); i++) {
            str.append((new StringBuilder()).append("{\"id\":\"").append(((Object[]) menuTree.get(i))[0])
                    .append("\",\"pId\":\"").append("\",\"name\":\"").append(((Object[]) menuTree.get(i))[1])
                    .append("\"},"));
        }

        String str1 = str.toString();
        if (str1.endsWith(","))
            str1 = str1.substring(0, str1.length() - 1);
        str1 = (new StringBuilder()).append(str1).append("]").toString();
        return str1;
    }

    /**
     * 查询会议室设置树数据
     * @param request
     * @param corpId
     * @return
     */
    public List<Map<String, Object>> getBoardroomDatas(List<Map> bsList, String corpId) {
    	List<Map<String, Object>> resultMap = null;
        if(CollectionUtils.isNotEmpty(bsList)) {
        	resultMap = new ArrayList<Map<String, Object>>();
        	Map<String, String> serveSetData = serveSetService.getServeSetData();
        	Map<String, Object> boardroomMap = null;
        	for(Map bs : bsList) {
        		boardroomMap = new HashMap<String, Object>();
        		String serverName = "";
        		if(!"".equals(StringUtils.null2String(bs.get("meetingServe")))) {
        			String[] bsArr = StringUtils.null2String(bs.get("meetingServe")).split(",");
        			for(int i = 0; i < bsArr.length; i++) {
        				if(serveSetData.get(bsArr[i]) != null) serverName += serveSetData.get(bsArr[i]) + (i == bsArr.length -1 ? "" : ",");
        			}
        		}
                boardroomMap.put("id", StringUtils.null2String(bs.get("id")));
                boardroomMap.put("title", StringUtils.null2String(bs.get("name")));
                boardroomMap.put("address", StringUtils.null2String(bs.get("address")) == "" ? StringUtils.null2String(bs.get("position")) : StringUtils.null2String(bs.get("address")));
                boardroomMap.put("tool", serverName);
                boardroomMap.put("isApprove", StringUtils.null2String(bs.get("isApprove")));
                boardroomMap.put("processCode", StringUtils.null2String(bs.get("progressId")));
                boardroomMap.put("limitDate", this.getLimitDate(Integer.parseInt(StringUtils.null2String(bs.get("beforeDays")))));
                boardroomMap.put("startTime", bs.get("startTime"));
                boardroomMap.put("endTime", bs.get("endTime"));
                
                resultMap.add(boardroomMap);
        	}
        }
        return resultMap;
    }
    
    /**
     * 查询会议室设置树数据(前后端分离前)
     * @param request
     * @param corpId
     * @return
     */
    public List<Map<String, Object>> getBoardroomData(List<BoardroomSet> bsList, String corpId) {
    	List<Map<String, Object>> resultMap = null;
        if(CollectionUtils.isNotEmpty(bsList)) {
        	resultMap = new ArrayList<Map<String, Object>>();
        	Map<String, String> serveSetData = serveSetService.getServeSetData();
        	Map<String, Object> boardroomMap = null;
        	for(BoardroomSet bs : bsList) {
        		boardroomMap = new HashMap<String, Object>();
        		String serverName = "";
        		if(StringUtils.isNotBlank(bs.getMeetingServe())) {
        			String[] bsArr = bs.getMeetingServe().split(",");
        			for(int i = 0; i < bsArr.length; i++) {
        				if(serveSetData.get(bsArr[i]) != null) serverName += serveSetData.get(bsArr[i]) + (i == bsArr.length -1 ? "" : ",");
        			}
        		}
                boardroomMap.put("id", bs.getId());
                boardroomMap.put("title", bs.getName());
                boardroomMap.put("address", bs.getPosition() == null ? bs.getAddress() : bs.getPosition());
                boardroomMap.put("tool", serverName);
                boardroomMap.put("isApprove",bs.getIsApprove());
                boardroomMap.put("processCode", bs.getProgressId());
                boardroomMap.put("limitDate", this.getLimitDate(bs.getBeforeDays()));
                resultMap.add(boardroomMap);
        	}
        }
        return resultMap;
    }
    
    public List<BoardroomSet> getBoardroomListByCateId(String cateId, String corpId){
    	return this.dao.getBoardroomList(cateId, corpId);
    }
    
    public List<Map> getBoardroomInfoList(String boardroomName, String categoryId, String count,
    		String meetingServe, String address, String corpId){
    	Map<String, Object> paramMap = new HashMap<String, Object>();
        StringBuffer sql = new StringBuffer();
        sql.append("select id,createdBy,createdDate,name,count,address,category_id categoryId,is_open isOpen,start_time startTime,end_time endTime,");
        sql.append(" meeting_serve meetingServe,sort_no sortNo,is_approve isApprove,progress_id progressId,corp_id corpId,position,before_days beforeDays,");
        sql.append(" scopeuse_user scopeuseUser");
        sql.append(" from oa_meeting_boardroom_set where ((is_approve = '1' and progress_id is not null) or is_approve = '0') ");
        sql.append(" and corp_id=:corpId and is_open=1");
        if(StringUtils.isNotBlank(boardroomName)) {
        	sql.append(" and name like :boardroomName");
        	paramMap.put("boardroomName", "%" + boardroomName + "%");
        }
        if(StringUtils.isNotBlank(categoryId)) {
        	sql.append(" and category_id=:categoryId");
        	paramMap.put("categoryId", categoryId);
        }
        if(StringUtils.isNotBlank(count)) {
        	sql.append(" and count = :count");
        	paramMap.put("count", count);
        }
        if(StringUtils.isNotBlank(meetingServe)) {
        	sql.append(" and meeting_serve like :meetingServe");
        	paramMap.put("meetingServe", "%" + meetingServe + "%");
        }
        if(StringUtils.isNotBlank(address)) {
        	sql.append(" and (address like :address or position like :address)");
        	paramMap.put("address", "%" + address + "%");
        }
        sql.append(" order by sort_no asc,createdDate desc");
        paramMap.put("corpId", corpId);
        return super.findByListNativeQuery(sql.toString(), null, paramMap);
    }
    
    /**
     * 查询会议室设置树数据
     * @param request
     * @param corpId
     * @return
     */
    public List<Map> getBoardroomData(String corpId) {
        Map<String, Object> paramMap = new HashMap<String, Object>();

        StringBuffer sql = new StringBuffer();
        sql.append("select s.id,s.name,s.progress_id,s.is_approve,s.scopeuse_user,s.before_days as beforeDays from oa_meeting_boardroom_set s ");
        sql.append(" left join oa_meeting_boardroom_cate ombcs on s.category_id = ombcs.id ");
        sql.append(" where s.corp_id = :corpId and ombcs.id is not null ");
        sql.append(" and ((s.is_approve = '1' and s.progress_id is not null) or s.is_approve = '0') ");
        paramMap.put("corpId", corpId);
        sql.append(" and s.is_open = '1' ");
        sql.append(" ORDER BY s.sort_no asc,s.createdDate desc");

        /*Query query = super.getQueryByNativeSQL(sql, paramMap);
        query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);*/
        List<Map> list = super.findByListNativeQuery(sql.toString(), "", paramMap);
        return list;
    }

    /**
     * 查询会议室
     * @param corpId
     * @param boardroomName 
     * @return
     */
    public List<BoardroomSet> getBoardroomSetList(String corpId, String boardroomName) {
    	List<BoardroomSet> bsList = new ArrayList<BoardroomSet>();
    	if(StringUtils.isNotBlank(boardroomName)){
    		bsList = this.dao.getRealBoardroomSetList(corpId,boardroomName);
        }else{
        	bsList = this.dao.getRealBoardroomSetList(corpId);
        }
    	return bsList;
//    	List<BoardroomSet> result = new ArrayList<>();
//    	if(bsList!=null){
//    		for (BoardroomSet boardroomSet : bsList) {
//            	BoardroomCategorySet set = this.categoryDingServvice.findOne(boardroomSet.getCategoryId());
//            	if(set != null){
//            		result.add(boardroomSet);
//            	}
//    		}
//    	}
//    	return result;
    }

    /**
     * 验证是否在会议室的时间段内
     * @param id:会议室id
     * @param startTime
     * @param endTime
     * @param corpId
     * @return
     */
    public String checkTime(String id, String startTime, String endTime, String corpId) {
        String msg ="";
        BoardroomSet boardroomSet = this.findOne(id);
        if(boardroomSet != null){
        	String startDate = startTime.substring(0,10);
            String endDate = endTime.substring(0,10);
            int beforeDate = boardroomSet.getBeforeDays();
            if(beforeDate > 0) {//验证提前预定时间
            	Long nowDate = DateUtils.parseDate(DateUtils.formatDate(new Date(), "yyyy-MM-dd")).getTime();
            	String limitDateStr = getLimitDate(beforeDate);
            	Long limitDate = DateUtils.parseDate(limitDateStr).getTime();
            	Long start = DateUtils.parseDate(startDate, "yyyy-MM-dd").getTime();
            	Long end = DateUtils.parseDate(endDate, "yyyy-MM-dd").getTime();
            	if(nowDate > start || end > limitDate) {
            		msg = "该会议室可提前" + beforeDate + "天预定，请重新选择";
            		return msg;
            	}
            }
            Long start = DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm").getTime();
            Long end = DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm").getTime();
            Long bsStart = DateUtils.parseDate(startDate + " " +boardroomSet.getStartTime(), "yyyy-MM-dd HH:mm").getTime();
            Long bsEnd = DateUtils.parseDate(startDate + " " +boardroomSet.getEndTime(), "yyyy-MM-dd HH:mm").getTime();
            if(!(start>=bsStart && start<=bsEnd && end>=bsStart && end<=bsEnd) ){
                msg = boardroomSet.getName()+"使用时段为"+boardroomSet.getStartTime()+"~"+boardroomSet.getEndTime();
            }
        }
        return msg;
    }
    
    /**
     * 根据会议室提前预定时间，获得可预定的最后一天日期
     * @param beforeDate
     * @return
     */
    public String getLimitDate(int beforeDate) {
    	if(beforeDate > 0) {
	    	GregorianCalendar gc = new GregorianCalendar();
	    	gc.setTime(new Date());
	    	gc.add(Calendar.DATE, beforeDate);
	    	return DateUtils.formatDate(gc.getTime(), "yyyy-MM-dd");
    	}
    	return "";
    }
    
    /**
     * 查询会议室类型下的会议室信息
     */
    public List<BoardroomSet> getBoardroomSetList(List<String> categoryIdList){
    	return this.dao.getBoardroomSetList(categoryIdList);
    }

    /**
     * 验证会议室是否可以删除
     * @param ids
     * @return
     */
	public String checkDeleteData(String[] ids) {
		String msg = "";
		if(ids!=null){
			List<BoardroomSet> bsList = new ArrayList<BoardroomSet>();
			for(String id:ids){
				List boardroomIdList = new ArrayList();
				boardroomIdList.add(id);
				List<ApplyRecord> arList = applyRecordService.getApplyRecordList(boardroomIdList);
				if(arList!=null && arList.size()>0){
					BoardroomSet bcs = this.findOne(id);
					bsList.add(bcs);
				}
			}
			if(bsList!=null && bsList.size()>0){
				for(BoardroomSet bs : bsList){
					msg += bs.getName()+"，";
				}
				msg = msg.substring(0,msg.length()-1);
				msg +="已有会议占用不可删除";
			}
		}
		return msg;
	}
	
	/**
     * 查询会议室设置数据
     * @param request
     * @param corpId
     * @return
     */
    public List<Map> getBoardroomSetList(String corpId) {
        int isOpen = 1;
        Map<String, Object> params = new HashMap<>();
        params.put("corpId", corpId);

        String sql = "select ombs.id value,ombs.name text,ombs.is_approve isApprove from oa_meeting_boardroom_set ombs ";
        sql +=" left join oa_meeting_boardroom_cate ombcs on ombs.category_id = ombcs.id ";
        sql += " where ombs.corp_id =:corpId and ombcs.id is not null ";
        sql +=" and ombs.is_open = '1'";
        sql += " ORDER BY ombs.sort_no asc,ombs.createdDate desc";

        /*Query query = super.getEntityManager().createNativeQuery(sql.toString());
        query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);*/
        List<Map> list = super.findByListNativeQuery(sql, "", params);
        return list;
    }
    
    /**
     * 查询会议申请选中的会议室
     * @param request
     * @param boardroomId
     * @return
     */
    public List<Map> getBoardroomSetCheckList(String ids) {
        if(StringUtils.isNoneEmpty(ids)){
            String[] strArr = ids.split(",");
            List<String> idList = new ArrayList<>();
            for(String id : strArr){
                idList.add(id);
            }
            Map<String, Object> params = new HashMap<>();
            params.put("ids", idList);
            String sql = "select ombs.id value,ombs.name text,oms.name adminName,address from oa_meeting_boardroom_set ombs ";
            sql += " join oa_meeting_apply_record_scope oms on ombs.admin_user_scope = oms.fieldDataValue";
            sql += " where ombs.id in (:ids) ";
            sql += " ORDER BY ombs.sort_no asc,ombs.createdDate desc";
            
            /*Query query = super.getEntityManager().createNativeQuery(sql.toString()).setParameter(1, idsStr);
            query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);*/
            List<Map> list = super.findByListNativeQuery(sql, "", params);
            return list;
        }
        return null;
    }
    
    /**
     * 查询会议室list
     * @param corpId
     * @return
     */
    public List<Map<String, Object>> getBoardroomList(String boardroomName, String corpId, String condition) {
    	List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
    	//查询会议室集合
        List<BoardroomSet> list = dao.getBoardroomSetList(corpId, boardroomName);
        if(CollectionUtils.isNotEmpty(list)){
        	Map<String, Object> bcsMap = new HashMap<String, Object>();
        	List<String> cateIds = new ArrayList<String>();
        	List<BoardroomSet> bsList = null;
        	for(BoardroomSet bs : list){
        		if(!cateIds.contains(bs.getCategoryId())) {
        			cateIds.add(bs.getCategoryId());
        			bsList = new ArrayList<BoardroomSet>();
        			bsList.add(bs);
        			bcsMap.put(bs.getCategoryId(), bsList);
        		}else {
        			List<BoardroomSet> tempList = (List<BoardroomSet>) bcsMap.get(bs.getCategoryId());
        			tempList.add(bs);
        		}
        	}
        	List<BoardroomCategorySet> bcsList = this.categoryDingServvice.getCategorytSetByIds(cateIds);
        	if(CollectionUtils.isNotEmpty(list)){
        		Map<String,Object> eleMap = new HashMap<String,Object>();
        		List<String> dateStrList = null;
        		for(BoardroomCategorySet bcs : bcsList){
        			dateStrList = new ArrayList<String>();
                    dateStrList.add(condition);
        			List<Map<String,Object>> boardroomList = this.applyRecordDingService
        					.getApplyRecordInfo((List<BoardroomSet>) bcsMap.get(bcs.getId()), dateStrList);
        			eleMap.put("boardroomList", boardroomList);
        			eleMap.put("category", bcs);
        			resultList.add(eleMap);
        		}
        	}
        }
        return resultList;
    }
    
    /**
     * 查询会议室list
     * @param corpId
     * @return
     */
    public List<Map<String, Object>> getBoardroomList(String corpId,String condition) {
        List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
        List<BoardroomCategorySet> bcsList = this.categoryDingServvice.getCategorySetList(corpId);
        if(bcsList!=null && bcsList.size()>0){
            for(BoardroomCategorySet bcs : bcsList){
                Map<String,Object> bcsMap = new HashMap<String,Object>();
                //查询会议室集合
                List<BoardroomSet> bsList = this.dao.getBoardroomListBpm(bcs.getId());
                List<Map<String,Object>> boardroomList = new ArrayList<Map<String,Object>>();
                if(bsList!=null && bsList.size()>0){
                    List<String> dateStrList = new ArrayList<String>();
                    dateStrList.add(condition);
                    boardroomList =  this.applyRecordDingService.getApplyRecordInfo(bsList, dateStrList);
                    bcsMap.put("boardroomList", boardroomList);
                    bcsMap.put("category", bcs);
                    list.add(bcsMap);
                }
            }
        }
        return list;
    }
    
    public List<Map<String, Object>> getBoardroomAdmin(String boardRoomId,String corpId,String token){
    	BoardroomSet boardroomSet = this.findOne(boardRoomId);
    	String scope = boardroomSet.getAdminUserScope();
    	List<String> list = this.popUserScopeUtilService.getScopeValue("oa_meeting_apply_record_scope", "oa_meeting_boardroom_set", "admin_user_scope", scope);
		String ids = "";
		List<Map<String, Object>> users = new ArrayList<>();
		if(list!=null && list.size()>0){
			for (String userId : list) {
				if(StringUtils.isNotBlank(userId)){
					ids += userId + ",";
				}
			}
		}
		if(ids != ""){
			ids = ids.substring(0,ids.length()-1);
		}
    	users = this.userApiService.getUserList(ids, corpId, "", token);
    	return users;
    }
    
}